package com.adopapa.ethexplorer.conf;

import java.time.ZoneId;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.web3j.protocol.Web3j;
import org.web3j.protocol.http.HttpService;

@Configuration
public class AppConfig {

	public final static ZoneId timeZone = ZoneId.of("Asia/Shanghai");

	@Value("${eth.http.host}")
	private String ethHttpHost;
	@Value("${eth.http.port}")
	private int ethHttpPort;
	@Value("${eth.sync.data}")
	private boolean ethSyncData;

	public String getEthHttpHost() {
		return ethHttpHost;
	}

	public void setEthHttpHost(String ethHttpHost) {
		this.ethHttpHost = ethHttpHost;
	}

	public int getEthHttpPort() {
		return ethHttpPort;
	}

	public void setEthHttpPort(int ethHttpPort) {
		this.ethHttpPort = ethHttpPort;
	}

	public boolean isEthSyncData() {
		return ethSyncData;
	}

	public void setEthSyncData(boolean ethSyncData) {
		this.ethSyncData = ethSyncData;
	}

	@Bean
	public Web3j web3j() {
		return Web3j.build(new HttpService(String.format("http://%s:%s", ethHttpHost, ethHttpPort)));
	}

//	@Bean
//	public ObjectMapper objectMapper() {
//		return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//	}

}
